<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta name="apple-wap-web-app-capable" content="yes">
		<meta name="apple-wap-web-app-status-bar-style" content="black-translucent">
		<meta name="MobileOptimized" content="240"/>
		<title>手机验证</title>
		<link rel="stylesheet" href="$!webPath/css/reset.css" />
		<link rel="stylesheet" href="$!webPath/css/style.css" />
		<script type="text/javascript" src="$!webPath/js/jquery.min.js" ></script>
	</head>
	<body>
		<div class="verify-top">为了更好的为您服务，请验证手机号：</div>
		<div class="input-top">
			<input type="text" placeholder="请输入手机号码" id="input_textT" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11"/>
		</div>
		<div class="input-bot">
			<input type="text" placeholder="请输入验证码" id="input_textM" onKeyUp="value=value.replace(/[\W]/g,'')" maxlength="6"/>
			<input type="button" value="获取验证码" id="input_buttonT" class="bbcw" />
		</div>
		<div class="verify-mid"></div>
		<div class="verify-mid-one">点击确定表示同意<a href="#">《勇士勋章用户服务协议》</a></div>
		<div class="verify-mid-two">
			<input type="button" value="确定" id="input_buttonM">
		</div>
		<script>
			jQuery("#input_buttonT").click(function(){
				var n = jQuery("#input_textT").val();
				if(n == false){
					jQuery(".verify-mid").text("号码不能为空！");
				}else if(n.length < 11){
					jQuery(".verify-mid").text("手机号码不能小于11位！");
				}else{

                        jQuery(".input-bot input[type=button]").addClass("g");
                        var wait = 60;
                        function time() {
                            if (wait == 0) {
                                jQuery("#input_buttonT").removeAttr("disabled").val("获取验证码").removeClass("g");
                                clearTimeout(a);
                            } else {
                                jQuery("#input_buttonT").attr("disabled", true).val("重新发送" + wait + "秒");
                                wait--;
                                a = setTimeout(time, 1000);
                            }
                        }
                        time();

					jQuery.ajax({
						url: "$!webPath/user/send_validate_code",
						type: "POST",
						data: {mobile: n},
						success: function (data) {
							console.log(data);
                            if (data.data == 'success') {
                            } else {
                                jQuery(".verify-mid").text(data.errorMsg);
                            }
						}
					});
				}
			});
			jQuery("#input_buttonM").click(function(){
				var n = jQuery("#input_textT").val();
				var c = jQuery("#input_textM").val();
				if(n == false){
					jQuery(".verify-mid").text("号码不能为空！");
				}else if(n.length < 11) {
					jQuery(".verify-mid").text("手机号码不能小于11位！");
				}else{
					jQuery.ajax({
						type: "POST",
						url: "$!webPath/user/validate_code",
						data: {mobile: n, code: c},
						success: function (data) {
							console.log(data);
							if (data.data == "success") {
								window.location.href = "$!webPath/user/my_account";
							} else {
								jQuery(".verify-mid").text("验证码错误");
							}
						}
					})
				}
			});
		</script>
	</body>
</html>
